// JavaScript Document
$(document).ready(function() {
var controlBar = $('#control-bar');
	if (controlBar.length > 0)
	{
		var cbPlaceHolder = controlBar.after('<div id="cb-place-holder" style="height:'+controlBar.outerHeight()+'px"></div>').next();		
		
		
		// Listener
		$(window).scroll(function()
		{
			// Check top position
			var controlBarPos = controlBar.hasClass('fixed') ? cbPlaceHolder.offset().top : controlBar.offset().top;
			$scroll = $(window).scrollTop();
			
			if ($scroll > controlBarPos)
			{
				if (!controlBar.hasClass('fixed'))
				{
					cbPlaceHolder.height(controlBar.outerHeight()).show();
					controlBar.addClass('fixed');
					$enable_cata = 0;					
				}
			}
			else
			{
				if (controlBar.hasClass('fixed'))
				{
					cbPlaceHolder.hide();
					controlBar.removeClass('fixed');
					$enable_cata = 1;
				}
			}
			
			if ($scroll > $('#point_cate').offset().top - controlBar.height())
			{				
				controlBar.addClass('unfixed');				
			}
			else
			{
				controlBar.removeClass('unfixed');
			}
		}).trigger('scroll');
	};
	
});